<template>
  <div class="container">

    <div class="input-group" v-if="SearchState">
      <input type="text" class="input-field" v-model="SearchValue" placeholder="请输入内容..." />
      <button class="submit-btn" @click="submit">搜索</button>
    </div>

    <div class="card">
      <h3 class="card-title">卡片标题</h3>
      <p class="card-description">这是卡片的描述内容，可以是关于文章的摘要、产品信息或其他任何简短说明。</p>
      <router-link to="/" class="card-link"> 跳转链接 </router-link>
    </div>
  </div>
</template>

<script setup lang="ts">
const SearchState: any = useSearch();

const SearchValue = ref("");

const router = useRouter();
const submit = () => {
  console.log(SearchValue.value);
  router.push({ path: `/search/${SearchValue.value}` });
};
</script>

<style scoped>
.container {
  width: 1600px;
  margin: 20px auto;
  max-width: 100%;
  box-sizing: border-box;

  display: flex;
  justify-content: center;
}

.card {
  width: 300px;
  padding: 20px;
  margin: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  text-align: center;
  background-color: #ffffff;
}

.card-title {
  margin-top: 0;
  color: #333;
}

.card-description {
  margin: 10px 0;
  line-height: 1.5;
  color: #666;
}

.card-link {
  display: inline-block;
  padding: 5px 10px;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 3px;
  transition: background-color 0.3s ease;
}

.card-link:hover {
  background-color: #0056b3;
}





.input-group {
  position: relative;
  width: 700px;
  margin: 20px auto;
}

.input-field {
  width: 600px;
  padding: 15px 20px;
  border-radius: 25px;
  border: 1px solid #ddd;
  outline: none;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
  font-size: 14px;
  transition: all 0.3s ease;
}

.input-field:focus {
  border-color: #007bff;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

/* 按钮样式 */
.submit-btn {
  position: absolute;
  right: 0;
  top: 0;
  width: 100px;
  height: 100%;
  padding: 0 20px;
  border: none;
  outline: none;
  background-color: #007bff;
  color: white;
  cursor: pointer;
  border-radius: 0 25px 25px 0;
  font-size: 14px;
  transition: all 0.3s ease;
}

.submit-btn:hover {
  background-color: #0056b3;
}

/* 输入框聚焦时按钮效果 */
.input-field:focus + .submit-btn {
  background-color: #0056b3;
}
</style>
